const express = require('express')
const pagesController = require('./controllers/pagesController')
const userController = require('./controllers/userController')
const postController = require('./controllers/postController')
const cateController = require('./controllers/cateController.js')
const uploadController = require('./controllers/uploadController')
const router = express.Router()
const optionsController = require('./controllers/optionsController')

//后台页面
router.get('/admin/index',pagesController.getAdminIndexPage)
.get('/admin/categories',pagesController.getAdminCategoriesPage)
.get('/admin/login',pagesController.getAdminLoginPage)
.get('/admin/comments',pagesController.getCommentsPage)
.get('/admin/nav-menus',pagesController.getNavMenusPage)
.get('/admin/passwordReset',pagesController.getPasswordResetPage)
.get('/admin/postAdd',pagesController.getPostAddPage)
.get('/admin/posts',pagesController.getPostsPage)
.get('/admin/profile',pagesController.getProfilePage)
.get('/admin/settings',pagesController.getSettingsPage)
.get('/admin/slides',pagesController.getSlidesPage)
.get('/admin/users',pagesController.getUsersPage)
.get('/getAllPost',postController.getAllPost)
.get('/getAllCate',cateController.getAllCate)


//前台页面
.get('/index',pagesController.getIndexPage)
.get('/list',pagesController.getListPage)
.get('/detail',pagesController.getDetailPage)
//业务处理路由
.post('/login',userController.login)

.post('/addPost',postController.addPost)
.get('/getPostById',postController.getPostById)
.post('/editPostById',postController.editPostById)
.get('/delPostById',postController.delPostById)


.get('/categoriesById',cateController.categoriesById)
.get('/categoriesAdd',cateController.categoriesAdd)
.get('/cateDelById',cateController.cateDelById)
.get('/delCateById',cateController.delCateById)

//option表的数据
.post('/addMenu',optionsController.addMenu)
.get('/getSettings',optionsController.getSettings)
.post('/updateSettings',optionsController.updateSettings)


//  文件上传
.post('/uploadFile',uploadController.uploadFile)

module.exports = router